import { ElMessage, ElNotification } from 'element-plus'

export function toast(message: string, type: string, isShowTitle = false) {
  let title = ''
  if (isShowTitle) {
    title = getTime()
  }

  return ElNotification({
    type,
    // @ts-ignore
    message,
    title: isShowTitle ? `嗨，${title}好` : '',
  })
}

export function getTime() {
  let title = ''
  let hours = new Date().getHours()
  if (hours <= 9) {
    title = '早上'
  } else if (hours <= 14) {
    title = '上午'
  } else if (hours <= 18) {
    title = '下午'
  } else {
    title = '晚上'
  }

  return title
}

export function getElMessage(message: string, type = 'success') {
  return ElMessage({
    type,
    // @ts-ignore
    message,
  })
}
